﻿from encodings import utf_8
from os import listdir
import requests
import urllib3

import json

from DataUnit.Cookie import CookieData

Urllist = [
    "https://api.bilibili.com/pgc/web/rank/list?day=3&season_type=1"     
  ];
#请求头
cookiedata = CookieData();
headers = {
   "Cookie" :cookiedata.getCookieStr(),
   "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0"
}


#第一个参数是实体对象，第二个是集合对象
for data  in Urllist :
    response = requests.get(data,headers=headers);
    response.encoding = utf_8;
    
    if response.status_code != 200 : 
        print("err")
    #加载json数据
    else: 
        data = json.loads(response.content); #loads读取的是json字符串，load是json、文件 print(data)
        listData = data["result"]["list"]
        print("番剧更新状态") 
       
        for data in listData:
             print(data["title"] +"|" + data["url"]);
       
    
    #打印数据
    #print(data)





